import React, { useContext, useMemo } from 'react'
import { SubmitBar, Checkbox } from 'react-vant';
import Ctx from './store/Ctx';


//底部组件
export default function Footer() {

    let obj = useContext(Ctx)

    //计算出全选
    let all = useMemo(() => {
        return obj.todolist.every(item => {
            return item.sed
        })
    }, [obj.todolist])

    return (
        <div>
            <SubmitBar
                price="3050"
                buttonText="提交订单"
            >
                <Checkbox checked={ all} onChange={(c)=>{
                    obj.dispatch({
                        type:'change_allsed',
                        payload:c
                    })
                }}>全选</Checkbox>
            </SubmitBar>
        </div>
    )
}
